Begin sltw_NR_KA_appletree

short apples
short currentday
short localdayspassed
short myapples

if ( apples == 0 )
	if ( OnActivate == 1 )
		set myapples to Random, 4
		if ( myapples == 3 )
			PlaceAtPC, "OBJECT_ID", 1, 10, 0
		endif
		if ( myapples >= 2 )
			PlaceAtPC, "OBJECT_ID", 1, 15, 1
		endif
		if ( myapples >= 1 )
			PlaceAtPC, "OBJECT_ID", 1, 20, 2
		endif
		if ( myapples >= 0 )
			PlaceAtPC, "OBJECT_ID", 1, 25, 3
		endif
		if ( myapples > 0 )
			MessageBox "Apples falls all around you."
		else
			MessageBox "An apple falls of the tree at your feet."
		endif
		Set apples to 1
	endif
endif

if ( apples == 1 )
	if ( OnActivate == 1 )
		MessageBox "No apples are ready to fall."
	endif
	set currentday to Day
	if ( currentday != Day )
		set currentday to Day
		set localdayspassed to ( localdayspassed + 1 )
	endif
	if ( localdayspassed == 3 )
		set localdayspassed to 0
		set apples to 0
	endif
endif

End